package view;
import java.awt.GridLayout;
import java.text.NumberFormat;

import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import model.Mp3Tags;

public class dataPane extends JPanel{ //Panel in dem sich die Textfelder und Label befinden
    	
    public dataPane(Mp3Tags currentMp3) {
        setLayout(new GridLayout(currentMp3.getNumberOfTags()/2, 2));
        addGUIelements(currentMp3);
    }
	
    // erstellt je nach Tag-Typ ein entsprechendes GUI-Element
	private void addGUIelements(Mp3Tags m) {
		for(int i = 0; i < m.getNumberOfTags(); i++) {
			JLabel label = new JLabel();
			label.setText(m.getTagNameByIndex(i) + ":");
			
			switch(i)
			{
				case Mp3Tags.TAG_ALBUM: 
				case Mp3Tags.TAG_ARTIST:
				case Mp3Tags.TAG_TITLE:
					JTextField basic = new JTextField();
					basic.setText(m.getValueByIndex(i));
					this.add(basic);
					
					break;
					
				case Mp3Tags.TAG_YEAR:
					JTextField year = new JFormattedTextField(NumberFormat.getNumberInstance());
					year.setText(m.getValueByIndex(i));
					this.add(year);
					
					break;
			}
		}
	}
}
